package com.system.demo.utils;

import com.system.demo.entity.database.Paper;
import com.system.demo.entity.excelFile.PaperDTOForExcel;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;

import static cn.hutool.core.date.DateUtil.formatLocalDateTime;
import static com.system.demo.service.constant.ApplicationStatus.getStatusDescription;
import static com.system.demo.service.constant.PaperConstant.getFinalLevel;
import static com.system.demo.service.constant.PaperConstant.getType;

public class PaperDTOMapper {
    public static String mapStatus(Integer status) {
        return getStatusDescription(status);
    }

    public static String mapType(Integer type) {
        return getType(type);
    }

    public static String mapFinalLevel(Integer level) {
        return getFinalLevel(level);
    }

    public static PaperDTOForExcel mapToExcelDTO(Paper paper) {
        PaperDTOForExcel excelDto = new PaperDTOForExcel();

        excelDto.setId(paper.getId());
        excelDto.setUid(paper.getUid());
        excelDto.setTitle(paper.getTitle());
        excelDto.setTopic(paper.getTopic());
        excelDto.setParticipantMembers(paper.getParticipantMembers());
        excelDto.setTeamRank(paper.getTeamRank());
        excelDto.setType(mapType(paper.getType()));
        excelDto.setStatus(mapStatus(paper.getStatus()));
        excelDto.setCreateTime(formatLocalDateTime(paper.getCreateTime()));
        excelDto.setSubmitTime(formatLocalDateTime(paper.getSubmitTime()));
        excelDto.setAwardTime(formatLocalDateTime(paper.getAwardTime()));
        excelDto.setCertificate(paper.getCertificate());
        excelDto.setFinalLevel(mapFinalLevel(paper.getFinalLevel()));
        excelDto.setPermissionTime(formatLocalDateTime(paper.getPermissionTime()));
        excelDto.setStudentClass(paper.getStuClass());
        excelDto.setStudentName(paper.getStuName());

        return excelDto;
    }
}